<template>
  <el-dialog
    :title="title"
    :close-on-click-modal="false"
    :visible.sync="visible"
    :before-close="cancel"
    class="JNPF-dialog JNPF-dialog_center"
    lock-scroll
    width="40%"
  >
    <el-row :gutter="15" class="">
      <el-form
        ref="elForm"
        :model="dataForm"
        :rules="rules"
        label-width="100px"
      >
       
      <el-col :span="24">
          <el-form-item label="所属校区">
            <el-select v-model="dataForm.FHOME" placeholder="请选择">
              <el-option
                v-for="item in options3"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

       <el-col :span="24">
          <el-form-item label="所属区域">
            <el-select v-model="dataForm.FPARENTNO" placeholder="请选择">
              <el-option
                v-for="item in options1"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="教学楼编号" class="required" prop="FCATNO">
            <el-input
              v-model="dataForm.FCATNO"
              placeholder="请输入"
              clearable
              :disabled="!insertorupdate"
              maxlength="8"
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item class="required" label="教学楼名称" prop="FCATNAME">
            <el-input
              v-model="dataForm.FCATNAME"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="教学楼类型">
            <el-select v-model="dataForm.FCATTYPE" placeholder="请选择">
              <el-option
                v-for="item in options2"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        
        <el-col :span="24">
          <el-form-item label="备注信息">
            <el-input
              v-model="dataForm.FADDRESS"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="排序">
            <el-input
              v-model="dataForm.FSEQNO"
              placeholder="请输入"
              type="number"
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="是否显示">
            <el-radio-group v-model="dataForm.FVISIBLE">
              <el-radio :label="1">否</el-radio>
              <el-radio :label="2">是</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>

      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button  v-if="insertorupdate" type="primary" v-loading="loading">确 定</el-button>
      <el-button v-else type="primary"  v-loading="loading">修 改</el-button>
    </span>
  </el-dialog>
</template>
<script>
import jnpf from "@/utils/jnpf"
export default {
  props: {
    parelist: {
      type: Array,
      default: []
    },
  },
  data() {
    return {
        title:"新增",
        dataForm:{
          FHOME:"奉贤海湾校区",
          FPARENTNO: "东区",
          FCATNO: "20E04",
          FCATNAME: "综合实验楼",
          FADDRESS: "",
          FSEQNO: 2,
          FVISIBLE: 1,
          FCATTYPE: "实验楼",
          FOPERATOR: "system",
          FUPDDATE: "2011-02-16T02:57:02.000+00:00"
        },
        rules: {
          FCATNO: [
                { required: true, message: '请输入教学楼编号', trigger: 'blur' },
            ],
            FCATNAME: [
                { required: true, message: '请输入教学楼名称', trigger: 'blur' },
            ],
        },
        catlist:[
        {id:"10",fullName:"面食"},
        {id:"11",fullName:"零食"},
      ],
      fvisiblelist:[
        {id:"1",fullName:"是"},
        {id:"2",fullName:"否"},
      ],
      //所属区域选择数据
      options1: [{
        value: '2001',
        label: '东区'
      }, {
        value: '2002',
        label: '南区'
      }],

      //所属区域选择数据
      options2: [{
        value: '2001',
        label: '教学楼'
      }, {
        value: '2002',
        label: '实验楼'
      }],

      options3: [{
          value: '10',
          label: '徐汇桂林路校区'
        }, {
          value: '20',
          label: '奉贤海湾校区'
        }],
      
      loading:false,
      visible:false,
      insertorupdate:true
    };
  },
  created() {
  },
  mounted() {},
  methods: {
    //
    init(id){
      this.dataForm.FCATNO= id || ''
        if(this.dataForm.FCATNO)
        {
            this.title="修改"
           this.insertorupdate=false;
        }
        else
        {
          this.insertorupdate=true;
            this.title="新增";
        }
        this.visible=true;
    },
    //
    cancel(){
        this.$refs.elForm.resetFields();
        this.visible=false;
    },
  },
};
</script>




